package pl.wr.physics.units.quantum.units;

import pl.wr.math.number.Fraction;

/**
 * In quantum mechanics and particle physics, spin is a fundamental
 * characteristic property of elementary particles, composite particles
 * (hadrons), and atomic nuclei. The spin quantum number is a quantum number
 * that parameterizes the intrinsic angular momentum (or spin angular momentum,
 * or simply spin) of a given particle.
 * 
 * @version 1.0
 * @author wieslaw.rodak
 * 
 */
public final class Spin {

    //TODO zmienic na Tensor
    public final Fraction spin;

    /** A spin representing "1/2". */
    public static final Spin ONE_HALF = new Spin(Fraction.ONE_HALF);

    /** A spin representing "0". */
    public static final Spin ZERO = new Spin(Fraction.ZERO);

    /** A spin representing "1". */
    public static final Spin ONE = new Spin(Fraction.ONE);

    /**
     * @param value
     */
    private Spin(Fraction value) {
        spin = value;
    }

    /**
     * @param multiply
     *            The multiply value of 1/2.
     */
    public Spin(int multiply) {
        spin = new Fraction(multiply, 2);
    }

    /**
     * @return The string representation (Boson/Fermion) of particle type.
     */
    public String getTypeParticle() {

        final double x = spin.doubleValue() % 1;

        if (0 == x) {
            return "Boson";
        } else {
            return "Fermion";
        }
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder(32);
        builder.append("Spin [spin=").append(spin).append(']');
        return builder.toString();
    }

}
